home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / CheckBook 2.1d1 / Sources / UThermView.cp < prev    next >
Encoding:
Text File  |  1995-12-04  |  3.8 KB  |  115 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UThermView.cp
  3. // Copyright ©1994 Access Informatics.
  4. //
  5. /*
  6.     History:
  7.         2/8/93    PBM Started history
  8.  
  9. */
  10. //----------------------------------------------------------------------------------------
  11.  
  12. #ifndef __UTHERMVIEW__
  13. #include "UThermView.h"
  14. #endif
  15.  
  16. #ifndef __UMACAPPUTILITIES__
  17. #include "UMacAppUtilities.h"
  18. #endif
  19.  
  20. #ifndef __UMENUMGR__
  21. #include "UMenuMgr.h"
  22. #endif
  23.  
  24. #ifndef __FONTS__
  25. #include "Fonts.h"
  26. #endif
  27.  
  28. //----------------------------------------------------------------------------------------
  29. // Constants:
  30.  
  31.     
  32. //========================================================================================
  33. // Global Initialization Procedure
  34. //========================================================================================
  35. #pragma segment MAOpen
  36. MA_DEFINE_CLASS_M1(TThermView, TView);
  37.  
  38. //----------------------------------------------------------------------------------------
  39. // InitUViewTherm: 
  40. //----------------------------------------------------------------------------------------
  41. #pragma segment DlgInit
  42.  
  43. void InitUThermView()
  44. {
  45.     // So the linker doesn't dead strip class info 
  46.     macroDontDeadStrip(TThermView);
  47. } // InitUViewTherm 
  48.  
  49.  
  50. //========================================================================================
  51. // CLASS TThermView
  52. //========================================================================================
  53.  
  54.  
  55. //----------------------------------------------------------------------------------------
  56. // TThermView::Initialize: 
  57. //----------------------------------------------------------------------------------------
  58. #pragma segment AOpen
  59.  
  60. TThermView::TThermView() // Override 
  61. {
  62.     fMaximumValue = 100;    // just a nominal value
  63.     fCurrentValue = 0;
  64.     
  65.  
  66. //----------------------------------------------------------------------------------------
  67. // Draw: 
  68. //----------------------------------------------------------------------------------------
  69. // There are two rectangles, the bar itself and the remainder area
  70. // they are drawn in the grey and light blue that the finder uses.
  71. #pragma segment ARes
  72.  
  73. void TThermView::Draw(const VRect& /* area */) // Override 
  74. {
  75.     CRect aQDRect;            // the view
  76.     CRect barQDRect;        // the bar
  77.     CRect remainderQDRect;    // the remainder of the bar area
  78.     
  79.     this->GetQDExtent(aQDRect);
  80.     barQDRect = remainderQDRect = aQDRect;
  81.     
  82.     if(fMaximumValue <= 0)
  83.         return;
  84.     
  85.     PenNormal();
  86.     
  87.     long width = aQDRect.right - aQDRect.left;        // full width of bar
  88.     
  89.     width = (width *  fCurrentValue) / fMaximumValue;
  90.     barQDRect.right = barQDRect.left + width;
  91.     remainderQDRect.left = remainderQDRect.right - width;
  92.     
  93.     SetIfColor(fBackColor);    // gRGB
  94.     PaintRect(aQDRect);    // paint the backround
  95.  
  96.     SetIfColor(fBarColor);    // draw the bar
  97.     PaintRect(barQDRect);
  98.     
  99.     SetIfColor(gRGBBlack);
  100.     FrameRect(aQDRect);
  101. } // TThermView::Draw 
  102.  
  103. void TThermView::SetMaximum(long value)
  104. {
  105.     fMaximumValue = value;
  106. }
  107.  
  108. void TThermView::SetCurrent(long value)
  109. {
  110.     fCurrentValue = value;
  111.     this->DrawContents();
  112. }
  113.  
  114. Boolean TThermView::HasColour